
import { searchOrderById } from '../services/order';

export default {
  namespace: 'myorderdetail',

  state: {
    orderDetail: {},
  },

  effects: {
    *searchOrderById({ payload }, { call, put }) {
      const response = yield call(searchOrderById, payload);
      // console.log(111, response);
      if (response.code === 0) {
        yield put({
          type: 'getOrderDetail',
          payload: response,
          tabData: payload.tabData,
        });
      } else {
        yield put({
          type: 'errorMsg',
          payload: {
            code: response.code,
            msg: response.msg,
          },
        });
      }
    },
  },

  reducers: {
    errorMsg(state, action) {
      return {
        ...state,
        isError: true,
        ...action.payload,
      };
    },
    getOrderDetail(state, action) {
      return {
        ...state,
        orderDetail: action.payload.data,
      };
    },
  },
};
